// 在这个js中设置请求

// 引入配置好的axios
import http from './http.js'
import api from './api.js'
export function userLogin(data) {
    return http({
        method: 'POST',
        url: api.login,
        data
    })
}

export function demo() {
    return http({
        method: 'GET',
        url: api.address,
    })
}

export function getGoods(data) {
    return http({
        method: 'GET',
        url: api.goods,
        params: data
    })
}
export function getDetailgoods(id) {
    return http({
        method: 'GET',
        url: `${api.goods}/${id}`,
    })
}
// 增加
export function getCart(data) {
    return http({
        method: 'POST',
        url: api.cart,
        data
    })
}
// 获取购物车信息
export function getCart2(data) {
    return http({
        method: 'GET',
        url: api.cart,
        params: data,
    })
}

export function getLunBos(data) {
    return http({
        method: 'GET',
        url: api.lunBo,
        params: data
    })
}

export function getRegister(data) {
    return http({
        method: 'POST',
        url: api.register,
        data
    })
}

export function getsms(data) {
    return http({
        method: 'POST',
        url: api.sms,
        data
    })
}

export function updateCart(id, data) {
    return http({
        // axios文档即可, PUT请求的使用方式和POST 类似
        method: 'PUT',
        url: api.cart + '/' + id,
        data
    })
}
export function delCart(id) {
    return http({
        method: 'DELETE',
        url: api.cart + '/' + id,

    })
}

export function Address(data) {
    return http({
        method: 'POST',
        url: api.address,
        data
    })
}

export function getCity() {
    return http({
        method: 'GET',
        url: api.city,

    })
}

export function getAddress() {
    return http({
        method: 'GET',
        url: api.address,
    })
}



export function updateAddress(id, data) {
    return http({
        // axios文档即可, PUT请求的使用方式和POST 类似
        method: 'PUT',
        url: api.address + '/' + id,
        data
    })
}
export function delAddress(id) {
    return http({
        method: 'DELETE',
        url: api.address + '/' + id,

    })
}

export function getOrder(data) {
    return http({
        method: 'POST',
        url: api.order,
        data
    })
}

export function getOrder2(data) {
    return http({
        method: 'GET',
        url: api.order,
        params: data
    })
}

export function getsingleOrder(id) {
    return http({
        method: 'GET',
        url: api.order + '/' + id,
    })
}